Part Number Hot Search : 
XD241 ULC831 8069X TA76432F ACT2X6 LTC24 TEF6606 PC818
Product Description
Full Text Search
 

To Download AN1241D Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  order this document by an1241/d an1241 ?mo torola, inc., 1995 an1241/d interfacing the mc68hc705j1a to 9356/9366 eepr oms by mark glenewinkel csic applications introduction this application note descr ibes the hardw are and softw are interf ace used to comm unicate betw een the freescale mc68hc705j1a mcu and 9356/9366 eeprom chips. the 93xx series of eeproms are an industr y standard used widely to store non v olatile bits of inf ormation. the softw are listing in this application note will w or k with 9356 and 9366 eepr oms . the eepr om bits are arr anged in 128 or 256 16-bit registers, respectively. with some modi?cation, the software will work with other 93xx series eeproms. some of the applications in which eeproms can be utilized are listed below. ? id number for remote addressing or security ? storage of telecommunication information like phone number recall and speed dialing ? power down information storage for consumer electronics like tvs and vcrs ? reprogrammable calibration data for test/measurement equipment the 93xx eepr oms comm unicate with the outside w or ld using a ser ial link. since the mc68hc705j1a does not ha v e the hardw are on chip to comm unicate to the eepr om, a softw are dr iv er is used. this method bit prog r ams an i/o por t to proper ly tr ansf er data to and from the eepr om. a national nm93c56n was used for testing the software routines in this application note. hardware interface the 9356 is a v er y simple 8-pin de vice . appendix a sho ws a typical connection betw een the mc68hc705j1a and the 9356. the ser ial interf ace connection uses only f our pins of the 9356. the y are as follows: ? cs chip select ? sk serial clock ? do serial data output ? di serial data input these signals m ust be cloc k ed in a cer tain wa y in order to tr ansf er the correct ser ial data to and from the mc68hc705j1a. f r e e s c a l e s e m i c o n d u c t o r , i f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 2 software interface communication betw een the mc68hc705j1a and the 9356 is done with a synchronous ser ial protocol. as mentioned ear lier , the mc68hc705j1a bit prog r ams its i/o pins to comm unicate with the 9356. a timing diagram of the serial link can be found in the 9356 data sheet if needed. the 9356 will accept seven different commands. they are as follows: 1) read read a 16-bit data word from an address in memory 2) write write a 16-bit data word from an address in memory 3) wrall write all addresses with the same 16-bit data word 4) erase erase a 16-bit data word from an address in memory 5) eral erase all addresses within the memory map 6) wen erase/write enable the eeprom memory 7) wds erase/write disable the eeprom memory the 9356 tr ansmission for mat is a fr ame of data bits containing an opcode , an address , and if needed, a w ord of data. the opcode is three bits long, the address is eight bits long, and the data w ord is 16 bits long. table 1 illustrates the bit information each instruction needs. table 1. implementation and test software was written to provide subroutines to perfor m each of the se ven commands . a total of f our bytes of ram are needed to support the subroutines. these bytes are described below. 1) op_code contains the opcode needed for the command 2) addr contains the address for the command 3) data_h the high byte for the data word 4) data_l the low byte for the data word as needed, each eepr om command subroutine will call other suppor ting subroutines to e x ecute the transmission of data between the mc68hc705j1a and the 9356. appendix b contains ?owcharts for all of these subroutines. instruction opcode address data read 110 a7Ca0 wen 100 11xxxxxx erase 111 a7Ca0 eral 100 10xxxxxx write 101 a7Ca0 d15Cd0 wrall 100 01xxxxxx d15Cd0 wds 100 00xxxxxx f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 3 each eepr om command subroutine has input data and output data. this data is inherent with some commands while others need the inf or mation passed to them bef ore the subroutine is called. t ab le 2 lists the input data needed and output data generated for each of the seven commands. code w as wr itten and tested with a le v el of quality equal to the car negie-mellon softw are engineer ing institute (sei) lev el 2. a test routine consisting of wr iting and reading the eepr om is listed in appendix c . refer to appendix a f or the schematic used in the design and test of the softw are . an led is used to v erify that the test code works properly. the test routine executes the following: 1) initializes the port on the hc705j1a for serial transmission. led is turned off. 2) writes eeprom address $00 with $aa55. 3) writes eeprom address $20 with $1234. 4) reads eeprom address $00 and stores it to ram location test1 and test2. 5) reads eeprom address $20 and stores it to ram location test3 and test4. 6) checks if test1 = $aa, test2 = $55, test3 = $12, and test4 = $34. 7) if check is good, then light the led. if check is bad, do not light the led. 8) continue to run in an in?nite loop until reset. for increased reliability, the software w atchdog on the mc68hc705j1a is used. also , a low voltage inhibit circuit, the mc34064, is used to decrease susceptibility to brown out or short power failure conditions. summary this application note has descr ibed the interf ace needed to successfully comm unicate betw een the mc68hc705j1a and the 9356. f or more inf or mation on the mc68hc705j1a, please consult the t echnical data man ual, mc68hc705j1a/d . contact national semiconductor or sgs thompson f or technical data on the 93xx series of eeprom memories. an electronic cop y of the code listing in appendix c and a listing of the test prog r am to fully test all the eepr om commands can be f ound on the freescale mcu bbs. the bbs number is (512) 891-3733. the ?lename is j1a_9356.arc and is on the csic bbs under the appnotes directory. also , freescale application note an1221/d further details the software and hardware interfaces needed between the 93xx series and other hc05 mcus. table 2: command subroutine input subroutine output read addr data_h/l ewen erase addr eral write addr & data_h/l wrall data_h/l ewds f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 4 appendix a f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 5 date: february 9, 1995 sheet 1 of 1 size document number rev a 705j1a.sch 1 title hc705j1a -> 93c56 eeprom freescale - csic strategic applications hc705j1a to 93c56 interface vcc 8 cs 1 gnd 5 sk 2 di 3 do 4 nc 6 nc 7 u2 nm93c56n vdd --> chip_select osc1 1 osc2 2 reset 20 irq/vpp 19 pa0 18 pa1 17 pa2 16 pa3 15 pa4 14 pa5 13 pa6 12 pa7 11 pb0 8 vss 10 vdd 9 pb1 7 pb3 5 pb2 6 pb4 4 pb5 3 u1 mc68hc705j1ap gnd vdd c1 0.1uf gnd 3 input 2 reset 1 u3 mc34064 vdd gnd vdd serial_clock serial_out serial_in --> --> <-- gnd d1 led vdd r1 390 gnd 3 2 1 x1 cer res f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 6 appendix b jsr j9356_ewen erase/write enable the eeprom main routine test test1 = $aa? initialize port a for bit programming led is off addr = $00 data_h = $aa data_l = $55 jsr j9356_eral erase all the eeprom jsr j9356_write write data to eeprom address test1 = data_h test2 = data_l addr = $00 test2 = $55? test3 = $12? test4 = $34? led is on test passed kick the wdog addr = $00 data_h = $12 data_l = $34 jsr j9356_write write data to eeprom address addr = $20 jsr j9356_read read data from eeprom address test3 = data_h test4 = data_l jsr j9356_read read data from eeprom address no no no no yes yes yes yes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 7 j9356_ewen opcode = $80 addr = $c0 cs = 1 jsr j9356_wr_op write the opcode j9356_ewds opcode = $80 addr = $00 cs = 1 jsr j9356_wr_addr write the address cs = 0 rts jsr j9356_wr_op write the opcode j9356_write opcode = $a0 cs =1 jsr j9356_wr_addr write the address rts jsr j9356_wr_data write the data ser_out = 0 cs = 0 jsr j9356_wait wait until eeprom is ready j9356_wral opcode = $80 addr = $40 cs = 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 8 jsr j9356_wr_op write the opcode j9356_erase opcode = $e0 cs =1 jsr j9356_wr_addr write the address rts cs = 0 jsr j9356_wait wait until eeprom is ready j9356_eral opcode = $80 addr = $80 cs = 1 jsr j9356_wr_op write the opcode j9356_read opcode = $c0 cs =1 jsr j9356_wr_addr write the address rts clock ser_clk jsr j9356_rd_data read the address ser_out = 0 cs = 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 9 j9356_wr_op x = 0? kick the wdog no yes put bit 7 of opcode on ser_out shift left opcode x = x-1 x=3 rts j9356_wr_addr x = 0? no yes put bit 7 of opcode on ser_out shift left addr x = x-1 x=8 rts j9356_wr_data x = 0? no yes put bit 7 of data_h on ser_out shift left data_l shift left data_h x = x-1 x=16 rts j9356_rd_data x = 0? no yes read ser_in put in c bit rotate left data_l rotate left data_h x = x-1 x=16 rts j9356_wait eeprom ready? ser_in = 0? no yes cs = 1 rts kick the wdog cs = 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 10 appendix c ***************************************************************************** ***************************************************************************** * * * main routine j1a_9356 - 705j1a to 9356 eeprom * * * ***************************************************************************** * * * file name: j1a_9356.rtn copyright (c) motorola 1995 * * * * full functional description of routine design: * * program flow: * * reset: initializes ports for bit banging. * * calls ewen sub to enable write to eeprom. * * calls eral to erase all eeprom * * writes $aa55 to eeprom $00 * * writes $1234 to eeprom $20 * * reads eeprom $00 and $20 * * check for correct data, light led if correct * * execute endless loop * * * ***************************************************************************** * * * part specific framework includes section * * * ***************************************************************************** #nolist #include 'h705j1a.frk' ;include the equates for the hc705j1a ;so that all labels can be used. #list ***************************************************************************** * * * mor bytes definitions for main routine * * * ***************************************************************************** org mor db $21 ;cop enabled, osc resistor enabled ;if used on a mask rom part, ; be sure to specify this option. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 11 ***************************************************************************** * * * * equates and ram storage * * * ***************************************************************************** * cs equ 0 ;bit # for chip select ser_clk equ 1 ;bit # for serial clock ser_out equ 2 ;bit # for serial data out ser_in equ 3 ;bit # for serial data in *** ram storage variables *** org ram ;start of static ram at $c0 opcode rmb 1 ;command byte addr rmb 1 ;eeprom address byte data_h rmb 1 ;msbyte of data data_l rmb 1 ;lsbyte of data test1 rmb 1 ;test byte #1 test2 rmb 1 ;test byte #2 test3 rmb 1 ;test byte #3 test4 rmb 1 ;test byte #4 ***************************************************************************** * * * * program initialization * * * * this section sets up the port for bit banging. * * * * to prevent floating inputs and associated high current draw, * * the hc705j1a has pulldown devices on all i/o pins. this * * initialization should enable these pulldowns on unused i/o * * pins. reset_ enables the pulldowns, so no code is required. * * * ***************************************************************************** * org eprom j9356_start lda #$80 ;init porta sta porta ; sta copr ;kick the wdog lda #$87 ;init i/o of port a sta ddra f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 12 ***************************************************************************** * * * j1a_9356 main program loop * * * * it then runs through the test routine to check for * * proper serial transmission. the led is lit if the test passes. * * * ***************************************************************************** *** enable erase/write mode of eeprom jsr j9356_ewen ;call ewen routine *** erase all eeprom memory map jsr j9356_eral ;call eral routine *** write $aa55 to $00 lda #$00 ;load address sta addr lda #$aa ;load data byte high sta data_h lda #$55 ;load data byte low sta data_l jsr j9356_write ;call write routine *** write $1234 to $20 lda #$20 ;load address sta addr lda #$12 ;load data byte high sta data_h lda #$34 ;load data byte low sta data_l jsr j9356_write ;call write routine *** read $00 lda #$00 ;load address sta addr jsr j9356_read ;call read routine lda data_h sta test1 ;store away data_h to test1 lda data_l sta test2 ;store away data_l to test2 *** read $20 lda #$20 ;load address sta addr jsr j9356_read ;call read routine lda data_h sta test3 ;store away data_h to test3 lda data_l sta test4 ;store away data_l to test4 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 13 *** check results of write and read, light led if good j9356_cksum lda test1 ;check test1 cmpa #$aa bne j9356_branch ;branch if no good, no led lda test2 ;check test2 cmpa #$55 bne j9356_branch ;branch if no good, no led lda test3 ;check test3 cmpa #$12 bne j9356_branch ;branch if no good, no led lda test4 ;check test4 cmpa #$34 bne j9356_branch ;branch if no good, no led bclr 7,porta ;eeprom write and read is good ; light led j9356_branch clra sta copr ;kick the wdog bra j9356_branch f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 14 ***************************************************************************** * * * eeprom command subroutines * * * * these 7 subroutines execute each of the 7 commands * * that the eeprom will respond to * * * ***************************************************************************** *** ewen - subroutine to enable write/erase ****************************** j9356_ewen lda #$80 ;load opcode sta opcode lda #$c0 ;load address sta addr bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address bclr cs,porta ;cs line is low rts ;return *** ewds - subroutine to disable write/erase ***************************** j9356_ewds lda #$80 ;load opcode sta opcode clr addr ;load addr bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address bclr cs,porta ;cs line is low rts ;return *** write - subroutine to write eeprom *********************************** j9356_write lda #$a0 ;load opcode sta opcode bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address jsr j9356_wr_data ;write data bclr ser_out,porta bclr cs,porta ;cs line is low jsr j9356_wait ;wait until eeprom is ready rts ;return f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 15 *** wral - subroutine to write all eeprom ******************************** j9356_wral lda #$80 ;load opcode sta opcode lda #$40 ;load addr sta addr bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address jsr j9356_wr_data ;write data bclr ser_out,porta bclr cs,porta ;cs line is low jsr j9356_wait ;wait until eeprom is ready rts ;return *** read - subroutine to read eeprom ************************************* j9356_read lda #$c0 ;load opcode sta opcode bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address bset ser_clk,porta ;clock the ee bclr ser_clk,porta jsr j9356_rd_data ;read data bclr ser_out,porta bclr cs,porta ;cs line is low rts ;return *** erase - subroutine to erase eeprom *********************************** j9356_erase lda #$e0 ;load opcode sta opcode bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address bclr cs,porta ;cs line is low jsr j9356_wait ;wait until eeprom is ready rts *** eral - subroutine to erase all eeprom ******************************** j9356_eral lda #$80 ;load opcode and addr sta opcode sta addr bset cs,porta ;cs line is high jsr j9356_wr_op ;write opcode jsr j9356_wr_addr ;write address bclr cs,porta ;cs line is low jsr j9356_wait ;wait until eeprom is ready rts f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 16 ***************************************************************************** * * * eeprom supporting subroutines * * * * these subroutines support the functions called from the command subs * * * ***************************************************************************** *** subroutine to write 3 bit opcode ************************************ j9356_wr_op ldx #3t ;init counter for loop1 * write to the serial output pin j9356_loop1 brclr 7,opcode,j9356_l1_2 ;if opcode bit7 = 0, goto l1_2 bset ser_out,porta ;ser_out = 1 bra j9356_l1_3 ;goto l1_3 j9356_l1_2 bclr ser_out,porta ;ser_out = 0 * clock the serial clock pin j9356_l1_3 bset ser_clk,porta ;ser_clk = 1 bclr ser_clk,porta ;ser_clk = 0 asl opcode ;rotate the opcode decx ;decrease counter loop bne j9356_loop1 ;is loop1 finished? clra sta copr ;kick the wdog rts ;return *** subroutine to write 8 bit address **************************************** j9356_wr_addr ldx #8t ;init counter for loop2 * write to the serial output pin j9356_loop2 brclr 7,addr,j9356_l2_2 ;if addr bit7 = 0, goto l2_2 bset ser_out,porta ;ser_out = 1 bra j9356_l2_3 ;goto l2_3 j9356_l2_2 bclr ser_out,porta ;ser_out = 0 * clock the serial clock pin j9356_l2_3 bset ser_clk,porta ;ser_clk = 1 bclr ser_clk,porta ;ser_clk = 0 asl addr ;rotate the addr decx ;decrease counter loop bne j9356_loop2 ;is loop2 finished? rts ;return f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 17 *** subroutine to write 16 bit data ****************************************** j9356_wr_data ldx #16t ;init counter for loop4 * write the serial output pin with data j9356_loop4 brclr 7,data_h,j9356_l4_2 ;if addr bit7 = 0, goto l4_2 bset ser_out,porta ;ser_out = 1 bra j9356_l4_3 ;goto l4_3 j9356_l4_2 bclr ser_out,porta ;ser_out = 0 * clock the serial clock pin j9356_l4_3 bset ser_clk,porta ;ser_clk = 1 bclr ser_clk,porta ;ser_clk = 0 asl data_l ;rotate the data_l rol data_h ;rotate the data_h decx ;decrease counter loop bne j9356_loop4 ;is loop4 finished? rts ;return *** subroutine to read 16 bit data *************************************** j9356_rd_data ldx #16t ;init counter for loop3 * read the serial input pin j9356_loop3 brclr ser_in,porta,j9356_l3 ;carry bit = serial in j9356_l3 rol data_l ;rotate left result rol data_h * clock the serial clock pin bset ser_clk,porta ;ser_clk = 1 bclr ser_clk,porta ;ser_clk = 0 decx ;decrease counter loop bne j9356_loop3 ;is loop3 finished? rts ;return * wait until write cycle is over j9356_wait bset cs,porta ;cs line is high j9356_w2 clra sta copr ;kick the wdog brclr ser_in,porta,j9356_w2 bclr cs,porta ;cs line is low rts ;return f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 18 ***************************************************************************** * * * interrupt and reset vectors for main routine * * * ***************************************************************************** org reset fdb j9356_start f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 19 notes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
an1241/d 20 notes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .


▲Up To Search▲   

 
Price & Availability of AN1241D

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X